<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">
<link href="https://cdn.bootcss.com/KaTeX/0.7.1/katex.min.css" rel="stylesheet">








<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="机器学习," />










<meta name="description" content="记录一下对SVM的学习和理解方便回忆">
<meta name="keywords" content="机器学习">
<meta property="og:type" content="article">
<meta property="og:title" content="SVM">
<meta property="og:url" content="http://ukaii.cn/2020/01/23/SVM/index.html">
<meta property="og:site_name" content="uKaii">
<meta property="og:description" content="记录一下对SVM的学习和理解方便回忆">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://ukaii.cn/2020/01/23/SVM/KTT.jpg">
<meta property="og:updated_time" content="2020-08-18T01:45:52.630Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="SVM">
<meta name="twitter:description" content="记录一下对SVM的学习和理解方便回忆">
<meta name="twitter:image" content="http://ukaii.cn/2020/01/23/SVM/KTT.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://ukaii.cn/2020/01/23/SVM/"/>





  <title>SVM | uKaii</title><!-- hexo-inject:begin --><!-- hexo-inject:end -->
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <!-- hexo-inject:begin --><!-- hexo-inject:end --><div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">uKaii</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-主页">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            主页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-标签">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-目录">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            目录
          </a>
        </li>
      
        
        <li class="menu-item menu-item-时间轴">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            时间轴
          </a>
        </li>
      
        
        <li class="menu-item menu-item-schedule">
          <a href="/schedule/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-calendar"></i> <br />
            
            日程表
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://ukaii.cn/2020/01/23/SVM/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="uKaii">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/assets/img/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="uKaii">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">SVM</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2020-01-23T21:17:29+08:00">
                2020-01-23
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/机器学习/" itemprop="url" rel="index">
                    <span itemprop="name">机器学习</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/机器学习/线性分类器/" itemprop="url" rel="index">
                    <span itemprop="name">线性分类器</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1,253字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  5min
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>记录一下对SVM的学习和理解方便回忆<br><a id="more"></a></p>
<h1 id="模型总览"><a href="#模型总览" class="headerlink" title="模型总览"></a>模型总览</h1><div class="table-container">
<table>
<thead>
<tr>
<th style="text-align:center">类别</th>
<th style="text-align:center">特点</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">线性可分支持向量机</td>
<td style="text-align:center">硬间隔最大化</td>
</tr>
<tr>
<td style="text-align:center">线性支持向量机</td>
<td style="text-align:center">软间隔最大化</td>
</tr>
<tr>
<td style="text-align:center">非线性支持向量机</td>
<td style="text-align:center">使用核函数</td>
</tr>
</tbody>
</table>
</div>
<h2 id="模型"><a href="#模型" class="headerlink" title="模型"></a>模型</h2><script type="math/tex; mode=display">
f(x)=\text{sign}(w)</script><h1 id="理解最大间隔"><a href="#理解最大间隔" class="headerlink" title="理解最大间隔"></a>理解最大间隔</h1><h2 id="函数间隔："><a href="#函数间隔：" class="headerlink" title="函数间隔："></a>函数间隔：</h2><script type="math/tex; mode=display">
\begin{aligned}
\hat\gamma_i&=|w\cdot x_i+b|\\
            &=y_i(w\cdot x_i+b)
\end{aligned} \tag{2.1}</script><h2 id="最小函数间隔："><a href="#最小函数间隔：" class="headerlink" title="最小函数间隔："></a>最小函数间隔：</h2><script type="math/tex; mode=display">
\hat\gamma=\min_{i=1,\cdots,N}\hat\gamma_i \tag{2.2}</script><h2 id="几何间隔："><a href="#几何间隔：" class="headerlink" title="几何间隔："></a>几何间隔：</h2><script type="math/tex; mode=display">
\begin{aligned}
\gamma_i&=|\frac{w}{\|w\|}\cdot x_i+\frac{b}{\|w\|}|\\
        &=y_i(\frac{w}{\|w\|}\cdot x_i+\frac{b}{\|w\|})
\end{aligned} \tag{2.3}</script><h2 id="最小几何间隔："><a href="#最小几何间隔：" class="headerlink" title="最小几何间隔："></a>最小几何间隔：</h2><script type="math/tex; mode=display">
\gamma=\min_{i=1,\cdots,N}\gamma_i\tag{2.4}</script><h2 id="函数间隔与几何间隔的关系"><a href="#函数间隔与几何间隔的关系" class="headerlink" title="函数间隔与几何间隔的关系"></a>函数间隔与几何间隔的关系</h2><script type="math/tex; mode=display">
\gamma_i=\frac{\hat\gamma_i}{\|w\|}</script><script type="math/tex; mode=display">
\gamma=\frac{\hat\gamma}{\|w\|}</script><h2 id="可以具体化优化问题为"><a href="#可以具体化优化问题为" class="headerlink" title="可以具体化优化问题为"></a>可以具体化优化问题为</h2><p>是函数间隔最小</p>
<script type="math/tex; mode=display">
\begin{aligned}
\max_{w,b}\quad&\gamma\\
\text{s.t.}\quad&\gamma_i\ge\gamma,\quad i=1,2,\cdots,N
\end{aligned}</script><script type="math/tex; mode=display">
\begin{aligned}
\max_{w,b}\quad&\frac{\hat\gamma}{\|w\|}\\
\text{s.t.}\quad&\frac{\hat\gamma_i}{\|w\|}\ge\frac{\hat\gamma}{\|w\|},\quad i=1,2,\cdots,N
\end{aligned}</script><script type="math/tex; mode=display">
\begin{aligned}
\max_{w,b}\quad&\frac{1}{\|w\|}\\
\text{s.t.}\quad&\hat\gamma_i\ge1,\quad i=1,2,\cdots,N
\end{aligned}</script><p>最小化</p>
<script type="math/tex; mode=display">
\begin{aligned}
\max_{w,b}\quad&\frac{2}{\|w\|} \\
\text{s.t.}\quad&y_i(w\cdot x_i+b)\ge1
\end{aligned} \tag{2.5}</script><h1 id="原问题"><a href="#原问题" class="headerlink" title="原问题"></a>原问题</h1><p>线性可分下的原问题</p>
<script type="math/tex; mode=display">
\begin{aligned}
\min_{w,b}\quad&\frac12\|x\|^2\\
\text{s.t.}\quad&y_i(w\cdot x_i+b)-1\ge0,\quad i=1,2,\cdots,N
\end{aligned} \tag{3.1}</script><p>线性不可分下的原问题：</p>
<script type="math/tex; mode=display">
\begin{aligned}
\min_{w,b}\quad&\frac12\|x\|^2+C\sum_{i=1}^N\xi_i\\
\text{s.t.}\quad&y_i(w\cdot x_i+b)\ge1-\xi_i,\quad i=1,2,\cdots,N\\
&\xi_i\ge0,\quad i=1,2,\cdots,N
\end{aligned} \tag{3.2}</script><p>对应的决策函数为：</p>
<script type="math/tex; mode=display">
f(x)=\text{sign}(w^*\cdot x+b^*)=\text{sign}(\sum_{i=1}^{m}\alpha_iy^{(i)}\langle x^{(i)},x\rangle+b) \tag{3.3}</script><script type="math/tex; mode=display">
\min_{w,b}\quad\frac12\|x\|^2+C \sum_{i=1}^{N}(max(0,1-y_iw^Tx_i)</script><h1 id="拉格朗日对偶"><a href="#拉格朗日对偶" class="headerlink" title="拉格朗日对偶"></a>拉格朗日对偶</h1><p>弱对偶对所有的优化问题都成立，无论原问题是什么形式，对偶问题都是凸优化问题。</p>
<p>用对偶问题求一个原问题的下界估计</p>
<img src="/2020/01/23/SVM/KTT.jpg">
<h2 id="强对偶"><a href="#强对偶" class="headerlink" title="强对偶"></a>强对偶</h2><p>原始问题是凸优化问题的情况下，一般都满足强对偶</p>
<h2 id="Slater条件"><a href="#Slater条件" class="headerlink" title="Slater条件"></a>Slater条件</h2><p>原问题为凸问题</p>
<p>首先要看我们的模型本身是否满足强对偶，Slater条件是满足强对偶的一种情况。</p>
<script type="math/tex; mode=display">
满足Slater条件\quad\to\quad强对偶</script><h2 id="KTT"><a href="#KTT" class="headerlink" title="KTT"></a>KTT</h2><p>而强对偶下的最优解一定是满足KTT条件的，所以我们可以通过KTT条件去筛选最优解，</p>
<p>而当原问题是凸问题的时候，满足KTT条件的点一定是最优解。</p>
<p>即弱对偶下KTT为必要条件，强对偶下KTT为充分条件</p>
<p>在强对偶下KTT为必要条件，如果原问题为凸问题，则变为充要条件</p>
<p>不清楚是否为凸优化：</p>
<script type="math/tex; mode=display">
(x^*,\alpha^*,\beta^*)是最优解\quad\to\quad(x^*,\alpha^*,\beta^*)满足KKT条件</script><p>原问题为凸优化问题：</p>
<script type="math/tex; mode=display">
(x^*,\alpha^*,\beta^*)是最优解\quad\leftrightarrow\quad(x^*,\alpha^*,\beta^*)满足KKT条件</script><p><a href="https://www.cnblogs.com/harvey888/p/7100815.html" target="_blank" rel="noopener">https://www.cnblogs.com/harvey888/p/7100815.html</a><a href="https://www.jianshu.com/p/96db9a1d16e9" target="_blank" rel="noopener">https://www.jianshu.com/p/96db9a1d16e9</a></p>
<p><a href="http://blog.pluskid.org/?p=702" target="_blank" rel="noopener">http://blog.pluskid.org/?p=702</a></p>
<p><a href="https://www.hrwhisper.me/" target="_blank" rel="noopener">https://www.hrwhisper.me/</a></p>
<h1 id="对偶问题"><a href="#对偶问题" class="headerlink" title="对偶问题"></a>对偶问题</h1><p>将原问题转换为对偶问题用到了拉格朗日对偶</p>
<p>线性可分的原问题可转化为对偶问题：</p>
<script type="math/tex; mode=display">
\begin{aligned}
\min_\alpha\quad&\frac12\sum_{i=1}^{N}\sum_{j=1}^{N}\alpha_i\alpha_jy_iy_j(x_i\cdot x_j)-\sum_{i=1}^{N}\alpha_i \\
\text{s.t.}\quad&\sum_{i=1}^N\alpha_iy_i=0\\
&\alpha_i\ge0\ ,\quad i=1,2,\cdots,N
\end{aligned} \tag{5.1}</script><p>线性不可分原问题可转化为对偶问题：</p>
<script type="math/tex; mode=display">
\begin{aligned}
\min_\alpha\quad&\frac12\sum_{i=1}^{N}\sum_{j=1}^{N}\alpha_i\alpha_jy_iy_j(x_i\cdot x_j)-\sum_{i=1}^{N}\alpha_i \\
\text{s.t.}\quad&\sum_{i=1}^N\alpha_iy_i=0\\
                &0\le\alpha_i\le C\ ,\quad i=1,2,\cdots,N
\end{aligned} \tag{5.2}</script><h1 id="核技巧"><a href="#核技巧" class="headerlink" title="核技巧"></a>核技巧</h1><h2 id="核技巧-1"><a href="#核技巧-1" class="headerlink" title="核技巧"></a>核技巧</h2><p>定义$\varphi(x)$为映射函数：把点$x$从原空间映射到新空间。通过$\varphi(x)$把数据映射到高维：</p>
<script type="math/tex; mode=display">
\begin{aligned}
\min_\alpha\quad&\frac12\sum_{i=1}^{N}\sum_{j=1}^{N}\alpha_i\alpha_jy_iy_j(\varphi(x_i)\cdot\varphi(x_j))-\sum_{i=1}^{N}\alpha_i \\
\text{s.t.}\quad&\sum_{i=1}^N\alpha_iy_i=0\\
                &0\le\alpha_i\le C\ ,\quad i=1,2,\cdots,N
\end{aligned} \tag{6.1}</script><p>定义函数$K(x_i,x_j)$：</p>
<script type="math/tex; mode=display">
K(x_i,x_j)=\varphi(x_i)\cdot\varphi(x_j) \tag{6.2}</script><p>问题可转化为：</p>
<script type="math/tex; mode=display">
\begin{aligned}
\min_\alpha\quad&\frac12\sum_{i=1}^{N}\sum_{j=1}^{N}\alpha_i\alpha_jy_iy_jK(x_i,x_j)-\sum_{i=1}^{N}\alpha_i \\
\text{s.t.}\quad&\sum_{i=1}^N\alpha_iy_i=0\\
&0\le\alpha_i\le C\ ,\quad i=1,2,\cdots,N
\end{aligned} \tag{6.3}</script><p>判别函数为:</p>
<script type="math/tex; mode=display">
\begin{aligned}
f(x)&=\text{sign}(w^*\cdot x+b^*)\\
&=\text{sign}(\sum_{i=1}^{m}\alpha_iy^{(i)}K(x^{(i)},x)+b)
\end{aligned}  \tag{6.4}</script><p>一个简单形式的核函数对应的$\varphi(x)$就可能很复杂。因此只需要寻找一个合适的核函数$K(x_i,x_j)$，就可以把数据映射到足够高维。避免了直接去计算$\varphi(x)$，大大减少了数据映射时的运算量。</p>
<h2 id="一个例子"><a href="#一个例子" class="headerlink" title="一个例子"></a>一个例子</h2><script type="math/tex; mode=display">
\varphi(\mathbf{x})=[1,x_1^2,\sqrt2x_1x_2,x_2^2,\sqrt2x_1,\sqrt2x_2]^T</script><p>$\mathbf{x<em>i}=[x</em>{i1},x<em>{i2}]^T$ $\mathbf{x_i}=[x</em>{j1},x_{j2}]^T$</p>
<script type="math/tex; mode=display">
\begin{aligned}
K(\mathbf{x_i},\mathbf{x_j})&=\varphi(\mathbf{x_i})\cdot\varphi(\mathbf{x_j})\\
          &=1+x_{i1}^2x_{j1}^2+2x_{i1}x_{i2}x_{j1}x_{j2}+x_{i2}^2x_{j2}^2+2x_{i1}x_{j1}+2x_{i2}x_{j2}\\
          &=(1+\mathbf{x_i}^T\mathbf{x_j})^2
\end{aligned}</script><h2 id="常用核函数"><a href="#常用核函数" class="headerlink" title="常用核函数"></a>常用核函数</h2><p>常用的核函数有（$K(x,z)$表示核函数，$f(x)$表示对应的判别函数）：</p>
<ul>
<li><p>多项式核函数：</p>
<ul>
<li><p>$K(x,z)=(x\cdot z+1)^p$</p>
</li>
<li><p>$f(x)=\text{sign}(\sum_{i=1}^{N_s}{a_i }y_i(x_i\cdot x+1)^p+b)$</p>
</li>
</ul>
</li>
<li><p>高斯核函数：</p>
<ul>
<li>$K(x,z)=\exp(-\frac{|x-z|^2}{2\sigma^2})$</li>
</ul>
</li>
<li><p>字符串核函数：</p>
</li>
</ul>
<h1 id="SMO算法"><a href="#SMO算法" class="headerlink" title="SMO算法"></a>SMO算法</h1><h1 id="其他形式"><a href="#其他形式" class="headerlink" title="其他形式"></a>其他形式</h1><div class="table-container">
<table>
<thead>
<tr>
<th></th>
<th>原问题</th>
<th>对偶问题</th>
</tr>
</thead>
<tbody>
<tr>
<td>L1正则化L2-loss SVC</td>
<td>坐标下降法</td>
<td>-</td>
</tr>
<tr>
<td>L2正则化L1-loss SVC （经典）</td>
<td>-</td>
<td>坐标下降法</td>
</tr>
<tr>
<td>L2正则化L2-loss SVC</td>
<td>可信域牛顿法</td>
<td>坐标下降法</td>
</tr>
<tr>
<td>L1-loss SVR</td>
<td>-</td>
<td>坐标下降法</td>
</tr>
<tr>
<td>L2-loss SVR</td>
<td>可信域牛顿法</td>
<td>坐标下降法</td>
</tr>
</tbody>
</table>
</div>
<p>并不一定要用拉格朗日对偶。</p>
<p>要注意用拉格朗日对偶并没有改变最优解，而是<strong>改变了算法复杂度</strong>：<br>在原问题下，求解算法的复杂度与样本维度（等于权值w的维度）有关；<br>而在对偶问题下，求解算法的复杂度与样本数量（等于拉格朗日算子a的数量）有关。</p>
<p>因此，如果你是做线性分类，且样本维度低于样本数量的话，在原问题下求解就好了，Liblinear之类的线性SVM默认都是这样做的；<br>但如果你是做非线性分类，那就会涉及到升维（比如使用高斯核做核函数，其实是将样本升到无穷维），升维后的样本维度往往会远大于样本数量，此时显然在对偶问题下求解会更好。</p>
<p>作者：一氧化二氢货<br>链接：<a href="https://www.zhihu.com/question/36694952/answer/69737932" target="_blank" rel="noopener">https://www.zhihu.com/question/36694952/answer/69737932</a><br>来源：知乎<br>著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。</p>
<h1 id="线性分类器比较"><a href="#线性分类器比较" class="headerlink" title="线性分类器比较"></a>线性分类器比较</h1><div class="table-container">
<table>
<thead>
<tr>
<th></th>
<th>模型</th>
<th style="text-align:center">学习准则</th>
<th>损失函数</th>
<th>优化方法</th>
</tr>
</thead>
<tbody>
<tr>
<td>线性回归</td>
<td>$w^Tx$</td>
<td style="text-align:center">最小二乘</td>
<td>$(y-w^Tx)^2$</td>
<td>梯度下降、正规方程</td>
</tr>
<tr>
<td>Logistic回归</td>
<td>$\sigma(w^Tx)$</td>
<td style="text-align:center">ML估计</td>
<td>$y\log\sigma(w^Tx)$</td>
<td>梯度下降</td>
</tr>
<tr>
<td>Softmax回归</td>
<td>$\text{softmax(}W^Tx)$</td>
<td style="text-align:center">ML估计</td>
<td>$y \text{log softmax}(W^Tx)$</td>
<td>梯度下降</td>
</tr>
<tr>
<td>感知器</td>
<td>$\text{sgn}(w^Tx)$</td>
<td style="text-align:center">-</td>
<td>$\max(0,-yw^Tx)$</td>
<td>随机梯度下降</td>
</tr>
<tr>
<td>支持向量机</td>
<td>$\text{sgn}(w^Tx)$</td>
<td style="text-align:center">最大化间隔</td>
<td>$\max(0,1-yw^Tx)$</td>
<td>二次规划、SMO</td>
</tr>
</tbody>
</table>
</div>
<p><a href="https://www.cnblogs.com/peyton-li/p/7620081.html" target="_blank" rel="noopener">svm与lr（逻辑回归）的区别</a><br><a href="https://blog.csdn.net/m0_37786651/article/details/61614865" target="_blank" rel="noopener">感知器、logistic与svm 区别与联系 - m0_37786651的博客 - CSDN博客</a><br><a href="https://blog.csdn.net/xiaoding133/article/details/9079103" target="_blank" rel="noopener">MLP、RBF、SVM网络比较及其应用前景 - xiaoding133的专栏【Stay hungry,Stay foolish】 - CSDN博客</a><br><a href="https://blog.csdn.net/power0405hf/article/details/53456162" target="_blank" rel="noopener">标准化、归一化、正则化</a></p>

      
    </div>
    
    
    

    

    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者：</strong>
    uKaii
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://ukaii.cn/2020/01/23/SVM/" title="SVM">http://ukaii.cn/2020/01/23/SVM/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>
    本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 3.0</a> 许可协议。转载请注明出处！
  </li>
</ul>

      </div>
    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/机器学习/" rel="tag"># 机器学习</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/12/23/使用MarkDown遇到的问题/" rel="next" title="使用MarkDown遇到的问题">
                <i class="fa fa-chevron-left"></i> 使用MarkDown遇到的问题
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2020/01/29/learning-theory/" rel="prev" title="learning-theory">
                learning-theory <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="SOHUCS"></div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/assets/img/avatar.jpg"
                alt="uKaii" />
            
              <p class="site-author-name" itemprop="name">uKaii</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives">
              
                  <span class="site-state-item-count">34</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">17</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">17</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#模型总览"><span class="nav-number">1.</span> <span class="nav-text">模型总览</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#模型"><span class="nav-number">1.1.</span> <span class="nav-text">模型</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#理解最大间隔"><span class="nav-number">2.</span> <span class="nav-text">理解最大间隔</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#函数间隔："><span class="nav-number">2.1.</span> <span class="nav-text">函数间隔：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#最小函数间隔："><span class="nav-number">2.2.</span> <span class="nav-text">最小函数间隔：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#几何间隔："><span class="nav-number">2.3.</span> <span class="nav-text">几何间隔：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#最小几何间隔："><span class="nav-number">2.4.</span> <span class="nav-text">最小几何间隔：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#函数间隔与几何间隔的关系"><span class="nav-number">2.5.</span> <span class="nav-text">函数间隔与几何间隔的关系</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#可以具体化优化问题为"><span class="nav-number">2.6.</span> <span class="nav-text">可以具体化优化问题为</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#原问题"><span class="nav-number">3.</span> <span class="nav-text">原问题</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#拉格朗日对偶"><span class="nav-number">4.</span> <span class="nav-text">拉格朗日对偶</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#强对偶"><span class="nav-number">4.1.</span> <span class="nav-text">强对偶</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Slater条件"><span class="nav-number">4.2.</span> <span class="nav-text">Slater条件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#KTT"><span class="nav-number">4.3.</span> <span class="nav-text">KTT</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#对偶问题"><span class="nav-number">5.</span> <span class="nav-text">对偶问题</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#核技巧"><span class="nav-number">6.</span> <span class="nav-text">核技巧</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#核技巧-1"><span class="nav-number">6.1.</span> <span class="nav-text">核技巧</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#一个例子"><span class="nav-number">6.2.</span> <span class="nav-text">一个例子</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#常用核函数"><span class="nav-number">6.3.</span> <span class="nav-text">常用核函数</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#SMO算法"><span class="nav-number">7.</span> <span class="nav-text">SMO算法</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#其他形式"><span class="nav-number">8.</span> <span class="nav-text">其他形式</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#线性分类器比较"><span class="nav-number">9.</span> <span class="nav-text">线性分类器比较</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">uKaii</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">14.0k</span>
  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Mist</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script><!-- hexo-inject:begin --><!-- Begin: Injected MathJax -->
<script type="text/x-mathjax-config">
  MathJax.Hub.Config("");
</script>

<script type="text/x-mathjax-config">
  MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
      all[i].SourceElement().parentNode.className += ' has-jax';
    }
  });
</script>

<script type="text/javascript" src="">
</script>
<!-- End: Injected MathJax -->
<!-- hexo-inject:end -->
  


  

  

</body>
</html>
